package com.jvm;

import jdk.internal.org.objectweb.asm.ClassWriter;
import jdk.internal.org.objectweb.asm.Opcodes;

/**
 * @Author: tgy
 * @Date: 2020-11-17 11:13
 */
public class MethodDemo01 extends ClassLoader{

    public static void main(String[] args) {

        int j = 0;

        try {
            MethodDemo01 methodDemo01 = new MethodDemo01();
            for (int i = 0; i < 10000; i++,j++) {



                ClassWriter classWriter = new ClassWriter(0);

                classWriter.visit(Opcodes.V1_8,Opcodes.ACC_PUBLIC,"Class" + i,null,"java/lang/Object",null);

                byte[] bytes = classWriter.toByteArray();

                methodDemo01.defineClass("Class" + i, bytes, 0, bytes.length);
            }

        }finally {

            System.out.println(j);
        }

    }
}
